<?php

/**
 * @package		Joomla
 * @subpackage	wbfirst
 * @copyright	2008 Wim Bekker, www.wimbekker.com.
 * @license		GNU/GPL
*/
 
// no direct access
/*defined( '_JEXEC' ) or die( 'Restricted access' );*/
 
jimport('joomla.application.component.controller');
 
class WbfirstsControllerWbfirst extends JController
{
  /**
   * constructor (registers additional tasks to methods)
   * @return void
   */
  function __construct()
  {
    parent::__construct();
 
    // Register Extra tasks
    $this->registerTask( 'add'  ,     'edit' );
  }

  /**
   * display the edit form
   * @return void
   */
  function edit()
  {
    JRequest::setVar( 'view', 'wbfirst' );
    //JRequest::setVar( 'layout', 'form'  );
    JRequest::setVar('hidemainmenu', 1);
 
    parent::display();
  }  
  /**
   * save a record (and redirect to main page)
   * @return void
   */
  function save()
  {
    $model = $this->getModel('wbfirst');
 
    if ($model->store()) 
    {
      $msg = JText::_( 'Greeting Saved!' );
    } 
    else 
    {
      $msg = JText::_( 'Error Saving Greeting' );
    }
 
    // Check the table in so it can be edited.... we are done with it anyway
    $link = 'index.php?option=com_wbfirst';
    $this->setRedirect($link, $msg);
  }
  /**
   * remove record(s)
   * @return void
   */
  function remove()
  {
    $model = $this->getModel('wbfirst');
    if(!$model->delete()) 
    {
      $msg = JText::_( 'Error: One or More Greetings Could not be Deleted' );
    } 
    else 
    {
      $msg = JText::_( 'Greeting(s) Deleted' );
    }
    
    $this->setRedirect( 'index.php?option=com_wbfirst', $msg );
  }  
  /**
   * cancel editing a record
   * @return void
   */
  function cancel()
  {
      $msg = JText::_( 'Operation Cancelled' );
      $this->setRedirect( 'index.php?option=com_wbfirst', $msg );
  }  
}

?>
